{extend name='Public:content'/}
{block name='title'}插件库{/block}
{block name='content'}
<div class="row animated fadeIn">
    <div class="row">
        <div class="col-md-5">
            <div class="panel panel-default tabs">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="active"><a href="#tab-first" role="tab" data-toggle="tab">插件列表
                        <button class="btn btn-success btn-rounded btn-sm">{$widgetsNums}</button>
                    </a></li>
                    <li><a href="#tab-second" role="tab" data-toggle="tab">添加插件模块</a></li>
                </ul>
                <div class="panel-body tab-content">
                    <div class="tab-pane active" id="tab-first">
                        {volist name='widget' id='v'}
                        <div class="col-md-12">
                            <div class="widget widget-{$v.wid_color} widget-item-icon">
                                <div title="{$v['wid_name']}【编辑】" data-url="{:url('admin/Setting/edit_plugins_page',['wid_id'=>$v.wid_id])}" onclick="edit_row(this)"  class="widget-item-left">
                                    <span class="{$v.wid_icon}"></span>
                                </div>
                                <div class="widget-data">
                                    <div class="widget-int num-count">{$v.wid_name}|{$v.wid_id}</div>
                                    {foreach name=":get_param_arr($v.wid_params)" item='k'}
                                    <div class="widget-subtitle">{$k}</div>
                                    {/foreach}
                                </div>
                                <div class="widget-controls">
                                    <a href="#" data-url="{:url('admin/Setting/del_plugins_think',['wid_id'=>$v.wid_id])}" onclick="del_wid(this)" class="widget-control-right widget-remove" data-toggle="tooltip" data-placement="top" title="删除模块"><span class="fa fa-times"></span></a>
                                </div>
                            </div>
                        </div>
                        {/volist}
                    </div>
                    <div class="tab-pane" id="tab-second">
                        <form id="add_form" action="{:url('admin/Setting/add_plugins_think')}" method="post" class="form-horizontal">
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-md-2 control-label">插件名称</label>
                                                <div class="col-md-8">
                                                    <div class="input-group">
                                                        <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                                        <input name="wid_name" type="text" class="form-control"/>
                                                    </div>
                                                    <span class="help-block"></span>
                                                </div>
                                            </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">参数</label>
                                            <div class="col-md-8">
                                                    <textarea name="wid_params" rows="3" class="form-control"></textarea>
                                                <span class="help-block">例:appid:xxxxxxx|key:xxxxxxx</span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">模块图标</label>
                                            <div class="col-md-8">
                                                <div class="input-group">
                                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                                    <input name="wid_icon" type="text" class="form-control"/>
                                                </div>
                                                <span class="help-block">例:'fa fa-github-alt'</span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">模块颜色</label>
                                            <div class="col-md-8">
                                                <div class="input-group">
                                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                                    <input name="wid_color" type="text" class="form-control"/>
                                                </div>
                                                <span class="help-block">例:'success,primary...'</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="panel-footer">
                                <button class="btn btn-info pull-right">保存添加<span class="fa fa-floppy-o fa-right"></span></button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function del_wid(dom) {
        layer.confirm('是否删除该条数据？', {
            btn: ['确认', '取消'],//按钮
            icon: 2
        }, function (index) {
            $.post($(dom).attr('data-url'), function (res) {
                destory();
                if (res.code) {
                    m_success(res.msg);
                    $(dom).parents(".widget").fadeOut(400, function () {
                        $(dom).remove();
                        $("body > .tooltip").remove();
                    });
                } else {
                    m_error(res.msg);
                }
                layer.close(index);

            })
        }, function () {
            m_warning('您已取消该操作');
        });
    }

</script>
{/block}